defaultHandleType = 0;
var win;

function handleDeal(msg, status, txt) {
	var url = context + '/app/qtfbl.do?method=handle&queryKey=' + querykey;

	Ext.MessageBox.confirm('提示', msg, function(e) {
				if (e == "yes") {
					Ext.MessageBox.wait('数据提交中...');
					Ext.Ajax.request({
								// 请求地址
								url : url,
								params : {
									id : id,
									H_STATUS : status,
									H_BACKINFO : txt
								},
								// 成功时回调
								success : function(response, options) {
									// 获取响应的json字符串
									Ext.MessageBox.hide();

									var json = response.responseText;
									var o = Ext.util.JSON.decode(json);

									if (o.success) {
										alert("提交成功！");
										handleBack();
									} else {
										Ext.Msg.alert('提示', '提交出现异常！');
									}
								}
							});
				}
			})
}

 function handleOK2(id) {
 	var fp = new Ext.FormPanel({
        fileUpload: true,
        width: 450,
        height:200,
        frame: true,
        autoHeight: true,
        bodyStyle: 'padding: 5px 5px 0 5px;',
        labelWidth: 70,
        defaults: {
            anchor: '95%',
            allowBlank: true,
            msgTarget: 'side'
        },
        items: [{
            xtype: 'textarea',
            fieldLabel: '处理意见',
            name : 'H_BACKINFO'
        },{
            xtype: 'fileuploadfield',
            id: 'form-file',
            emptyText: '请选择附件',
            fieldLabel: '附          件',
            name: 'HFFJ',
            buttonText: '',
            buttonCfg: {
                iconCls: 'upload-icon'
            }
        }]
        /*,
        buttons: [{
            text: '提交',
            handler: function(){
                if(fp.getForm().isValid()){
	                fp.getForm().submit({
	                    url: 'file-upload.php',
	                    waitMsg: 'Uploading your photo...',
	                    success: function(fp, o){
	                        msg('Success', 'Processed file "'+o.result.file+'" on the server');
	                    }
	                });
                }
            }
        },{
            text: '重置',
            handler: function(){
                fp.getForm().reset();
            }
        }]*/
    });	
 	
 	
    // create the window on the first click and reuse on subsequent clicks
    if(!win){
        win = new Ext.Window({
            layout:'fit',
        	title: '处理意见',
            width:600,
            modal:true,
            closeAction:'hide',
            plain: true,
            items: fp,
            buttons: [{
                text:'提交',
                handler: function(){
                if(fp.getForm().isValid()){
	                fp.getForm().submit({
	                    url : context + '/app/qtfbl.do?method=handle&queryKey=' + querykey,
	                    params : {
						id : id
						},
	                    waitMsg: '提交中...',
	                    success: function(form, action){
	                        //msg('成功', '提交数据成功');
	                        handleBack();
	                    },
	                    failure :function(form, action){
//	                    	var json = action.responseText;
//	                    	var o = Ext.util.JSON.decode(json);
	                    	Ext.Msg.alert('提示', action.result.msg);
	                    	win.hide();
	                    }
	                });
                }
            }
            },{
                text: '取消',
                handler: function(){
                	fp.getForm().reset();
                    win.hide();
                }
            }]
        });
    }
    win.show();
    }

/**
 * 办理通过
 */
function handleOK(id) {
	Ext.MessageBox.show({
				title : '处理意见',
				msg : '请填写接访处理意见:',
				width : 400,
				height : 400,
				buttons : Ext.MessageBox.OKCANCEL,
				multiline : true,
				fn : function(btn, text) {
					showResultText(btn, text, id);
				}
			});
}

function showResultText(btn, text, id) {
	if (btn == 'ok') {
		var url = context + '/app/qtfbl.do?method=handle&queryKey=' + querykey;

		Ext.MessageBox.wait('提交数据中...');
		Ext.Ajax.request({
					// 请求地址
					url : url,
					params : {
						id : id,
						H_BACKINFO : text
					},
					// 成功时回调
					success : function(response, options) {
						// 获取响应的json字符串
						Ext.MessageBox.hide();

						var json = response.responseText;
						var o = Ext.util.JSON.decode(json);

						if (o.success) {
							alert("提交成功！");
							handleBack()
						} else {
							Ext.Msg.alert('提示', '提交出现异常！');
						}
					}
				});
	}
}